package tote.services;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;

import tote.context.AppContext;
import tote.model.BetByGroup;

public class BetByGroupBean {
    protected final Log log = LogFactory.getLog(getClass());
    private List<BetByGroup> dataList;
    protected ApplicationContext ctx = AppContext.getApplicationContext();

    // Actions -----------------------------------------------------------------------------------
    public String saveDataList() {
	log.info("Saving position of teams");
	try {
	    UserService us = (UserService) ctx.getBean("userService");
	    us.saveBetsByGroup(dataList);
	} catch (Exception e) {
	    log.error("Can't save position of teams", e);
	}

	return "proceed"; // Navigation case.
    }

    public void setDataList(List<BetByGroup> dataList) {
	this.dataList = dataList;
    }

    public List<BetByGroup> getDataList() {
	UserService us = (UserService) ctx.getBean("userService");
	dataList = us.findBetsByGroup();
	return dataList;
    }
}
